import request from '@/utils/request';
import { ApiResult } from '@/api';

export async function uploadAvatar(data) {
  const res = await request.post<ApiResult<unknown>>('/file/upload', data);
  if (res.data.code === 0) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.message));
}

export async function updateUser(data) {
  const res = await request.put<ApiResult<unknown>>('/system/user', data);
  if (res.data.code === 0) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.message));
}
